package com.fenghongzhang.day005;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

public class MainActivity extends AppCompatActivity {

    private EditText edit;
    private Button btn;
    private LinearLayout ll;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        edit = (EditText) findViewById(R.id.edit);
        btn = (Button) findViewById(R.id.btn);
        ll = (LinearLayout) findViewById(R.id.ll);

    }

    public void btn(View view) {
        String string = edit.getText().toString();

        FragmentManager supportFragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
        ContentFragment contentFragment = new ContentFragment();
        Bundle bundle = new Bundle();
        bundle.putString("name",string);
        contentFragment.setArguments(bundle);
        fragmentTransaction.replace(R.id.ll,contentFragment); //remove add
        fragmentTransaction.commit();


    }
}
